package com.example.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * <P> @Author: SongKeCheng
 * <P> Type: Class
 * <P> Description:
 * <P> Date: 2024/7/15:9:38
 */

@SuppressWarnings({"unchecked", ""})
public class GroupUtils {
    private static final Logger log = LoggerFactory.getLogger(GroupUtils.class);

    /**
     * 09:58:48.568 [main] INFO com.example.utils.GroupUtils - 创建分组：[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
     * 09:58:48.572 [main] INFO com.example.utils.GroupUtils - 乱序分组：[3, 2, 6, 9, 4, 7, 1, 5, 10, 8]
    */
    public static void main(String[] args) {
        List<Integer> list= createGroup(10);
        log.info("创建分组：{}",list);
        Collections.shuffle(list);
        log.info("乱序分组：{}",list);
    }

    private static List<Integer> createGroup(int i) {
        List<Integer> list = new ArrayList<>();
        for (int j = 0; j < i; j++) {
            list.add(j+1);
        }
        return list;
    }
}
